<page-header [autoTitle]="false"></page-header>
<nz-card>
  <section class="search-section">
    <input nz-input placeholder="标题" [(ngModel)]="keyword" class="search-item"/>
    <nz-select [(ngModel)]="status" [nzPlaceHolder]="'是否上架'" class="search-item" [nzAllowClear]="true" [nzShowSearch]="true">
      <nz-option
        *ngFor="let option of yesOrNo"
        [nzLabel]="option.value"
        [nzValue]="option.key">
      </nz-option>
    </nz-select>
    <button nz-button [nzType]="'primary'" nzGhost (click)="search()"  class="search-item">
      <i class="anticon anticon-search"></i><span>搜索</span>
    </button>
    <button nz-button [nzType]="'primary'" (click)="addEntity()"  class="search-add-right">
      <i class="anticon anticon-plus"></i><span>添加</span>
    </button>
  </section>
  <nz-table #nzTable [nzData]="page.content"
            [nzPageSize]="page.size"
            [nzTotal]="page.totalElements"
            [nzFrontPagination]="false"
            [(nzPageIndex)]="page.number"
            (nzPageIndexChange)="changePageNo($event)"
            [nzLoading]="isLoading">
    <thead>
    <tr>
      <th nz-th><span>序号</span></th>
      <th nz-th><span>标题</span></th>
      <th nz-th><span>浏览次数</span></th>
      <th nz-th><span>排序号</span></th>
      <th nz-th><span>上架</span></th>
      <th nz-th><span>操作</span></th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of nzTable.data;let i=index">
      <td>
        {{i+1}}
      </td>
      <td>{{data.title}}</td>
      <td>{{data.views}}</td>
      <td>{{data.sortNum}}</td>
      <td>{{data.status|yesNoPipe}}</td>
      <td>
        <a href="javascript:void (0);" routerLink="/activity/list/edit" [queryParams]="{id: data.id}">查看详情</a>
        <nz-divider nzType="vertical"></nz-divider>
        <nz-popconfirm [nzTitle]="'确定要下架这条数据吗？'" (nzOnConfirm)="auditing(data)">
          <a nz-popconfirm *ngIf="data.status == 1">下架</a>
        </nz-popconfirm>
        <nz-popconfirm [nzTitle]="'确定要上架这条数据吗？'" (nzOnConfirm)="auditing(data)">
          <a nz-popconfirm *ngIf="data.status == 2">上架</a>
        </nz-popconfirm>
      </td>
    </tr>
    </tbody>
  </nz-table>
</nz-card>
